/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package SolvedProblems;

import java.io.File;
import java.util.Scanner;

/**
 *problem 499
 * @author Power User
 */
public class Frequency {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        new Frequency().begin();

    }//end main

    void begin(){
        File f = new File("input.txt");
        try{
            Scanner scan = new Scanner(f);
            while(scan.hasNextLine()){
                int[] lower = new int[26];
                int[] upper = new int[26];
                String line = scan.nextLine();
                char[] charArr = line.toCharArray();
                int max = -1000;
                for(int i = 0; i < line.length(); i++){
                    char ch = charArr[i];
                    if(Character.isLetter(ch)){
                        int curFreq = 0;
                        if(ch >= 'a' && ch <= 'z'){
                            curFreq = ++lower[ch - 'a'];
                        }else{
                            curFreq = ++upper[ch - 'A'];
                        }
                        if(max <= curFreq){
                            max = curFreq;
                        }
                    }
                }//end for
                String strU = "";
                String strL = "";
                for(int i = 0; i < 26; i++){
                    if(upper[i] == max){
                        char letter  = (char) (i + 'A');
                        strU = strU + letter;
                    }
                    if(lower[i] == max){
                        char letter  = (char) (i + 'a');
                        strL = strL + letter;
                    }
                }
                System.out.println(strU + strL + " " + max);
            }//end while
        }catch(Exception ex){

        }//end try catch
    }

}//end class
